<template>
  <el-container class="layout-ltb">
    <el-container>
      <el-main>
        <div>
          <el-form
            ref="formRef"
            :model="form"
            size="default"
            label-position="left"
            class="mt-[20px]"
            label-width="100"
          >
            <el-form-item label="用户名:">
              <el-input v-model="form.operatorCode" readonly />
            </el-form-item>

            <el-form-item label="所属公司:" class="mt-[12px!important]">
              <el-input v-model="form.companyName" readonly />
            </el-form-item>

            <el-form-item label="所属分公司:" class="mt-[12px!important]">
              <el-input v-model="form.subCompanyName" readonly />
            </el-form-item>

            <el-form-item label="系统部门:" class="mt-[12px!important]">
              <el-input v-model="form.departmentName" readonly />
            </el-form-item>

            <el-form-item label="真实姓名:" class="mt-[12px!important]">
              <el-input v-model="form.operatorName" readonly />
            </el-form-item>

            <el-form-item label="电话:" class="mt-[12px!important]">
              <el-input v-model="form.operatorTelephone" readonly />
            </el-form-item>
          </el-form>
          <el-button
            type="primary"
            disabled
            class="w-[80%] ml-[10%] mt-[40px] pt-[15px] pb-[15px]"
          >
            请前往营收系统修改个人信息/密码
          </el-button>
        </div>
      </el-main>
    </el-container>
  </el-container>
</template>

<script setup lang="ts">
defineOptions({
  name: "Inspection",
  inheritAttrs: false,
});
import TaskSetAPI from "@/api/TaskSetAPI";
const formRef = ref(ElForm);
const form = ref({
  operatorCode: "",
  companyName: "",
  subCompanyName: "",
  departmentName: "",
  operatorName: "",
  operatorTelephone: "",
});
function f_HandelQuery() {
  TaskSetAPI.api_query_userinfo().then(({ data, succeeded }) => {
    if (succeeded) {
      form.value.operatorCode = data.operatorName;
      form.value.companyName = data.companyName;
      form.value.subCompanyName = data.subCompanyName;
      form.value.operatorName = data.operatorName;
      form.value.operatorTelephone = data.operatorTelephone;

      if (data.departments && data.departments.length > 0) {
        let depArr = [];
        data.departments.forEach((item) => {
          depArr.push(item.departmentName);
        });
        form.value.departmentName = depArr.join(",");
      }
    }
  });
}
onMounted(() => {
  f_HandelQuery();
});
</script>
<style scoped lang="scss">
.el-main {
  div {
    width: 600px;
    margin: 0 auto;
  }
}
</style>
